
package com.aceitunaproject.server.materialgoods;

import com.aceitunaproject.server.ServerConfiguration;
import com.aceitunaproject.server.equipment.Equipment;

/**
 * 
 * Represents a Type of Material Good, ie Sugar, Gold, Computers
 * 
 * @author Federico Bergstein
 *
 */
public class MaterialGood {
	
	/**
	 * The nature of the MG as Equipment for units
	 */
	private Equipment asEquipment;
	
	/**
	 * The default non-localized name of the MG
	 */
	private String defaultName;

	/**
	 * Sets the nature of the MG as Equipment for units
	 * @param asEquipment The nature of the MG as Equipment for units
	 */
	public void setAsEquipment(Equipment asEquipment) {
		this.asEquipment = asEquipment;
	}

	/**
	 * Gets the nature of the MG as Equipment for units
	 * @return The nature of the MG as Equipment for units
	 */
	public Equipment getAsEquipment() {
		return asEquipment;
	}

	/**
	 *Sets the name for this kind of Material
	 *
	 * @param defaultName the name for this kind of Material
	 */
	public void setDefaultName(String defaultName) {
		this.defaultName = defaultName;
	}

	/**
	 * Gets the default non-localized name of the MG
	 * @return the default non-localized name of the MG
	 */
	public String getDefaultName() {
		return defaultName;
	}
	
	public boolean equals(Object anObject)
	{
		if (!super.equals(anObject)) {
			if (anObject instanceof MaterialGood) {

				MaterialGood comparisonObject = (MaterialGood) anObject;

				return (this.getDefaultName() == comparisonObject.getDefaultName());

			} else {
				return false;
			}
		} else {
			return true;
		}
	}

	public boolean isFood() {
		
		return ServerConfiguration.getFoodGoods().contains(this.getDefaultName());
	}

}
